<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>方法的重写</title>
</head>
<body>
    <script>
        class Common{
            getLessonByKey(key){
                return (this.data).filter(item => item.name.includes(key))
            }
        }

        class Controller extends Common{}

        class Lesson extends Controller{
            constructor(data){
                super();
                this.data = data;
            }

            // 重写父类的方法
            getLessonByKey(key){
                return super.getLessonByKey(key).map(item => item.name);
            }
        }

        let data = [
            {"name":"js","price":199},
            {"name":"html","price":99},
            {"name":"vue.js","price":169},
        ];

        let less = new Lesson(data);
        console.log(less.getLessonByKey("js"));
    </script>
</body>
</html>